package jk.zmn.thread.create;

/**
 * @author 张梦楠
 * @Title: ${file_name}
 * @Package ${package_name}
 * @Description: ${todo}
 * @date 2018/5/2615:08
 * @blog www.itzmn.com
 *
 *  模拟12306售票系统
 *
 */
public class Web12306 implements Runnable {


    private int num=50;//50张票
    @Override
    public void run() {

        while (true){
            if (num<0){
                break;
            }
            try {
                Thread.sleep(200);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName()+"售出了第"+num+"张票");
            num--;
        }
    }
     public static void main(String[] args) {
         Web12306 web12306 = new Web12306();
         //代理类
         Thread demo1 = new Thread(web12306, "黄牛1");
         Thread demo2 = new Thread(web12306, "黄牛2");
         Thread demo3 = new Thread(web12306, "黄牛3");
         demo1.start();
         demo2.start();
         demo3.start();
     }
}
